﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tasker.Infrastructure.Entities.Base;

namespace Tasker.Infrastructure.Repositories.Base
{
    public interface ICrudRepository<EntityType> : IRepository
        where EntityType : IEntity
    {
        /// <summary>
        /// Select single Entity by its Identifier
        /// </summary>
        /// <param name="id">Identifier of entity</param>
        /// <returns>Entyti with requered identifier or null</returns>
        EntityType SelectById(int id);

        /// <summary>
        /// Select all entities
        /// </summary>
        /// <returns>All enities</returns>
        IEnumerable<EntityType> SelectAll();

        /// <summary>
        /// Update entity to database
        /// </summary>
        /// <param name="entity">Entity to update (Id property must be setted)</param>
        void Update(EntityType entity);

        /// <summary>
        /// Indert new entity to database
        /// </summary>
        /// <param name="entity">Entity to insert (Id property must be setted)</param>
        EntityType Insert(EntityType entity);

        /// <summary>
        /// Create entity
        /// </summary>
        EntityType Create();

        /// <summary>
        /// Delete existing entity from database
        /// </summary>
        /// <param name="entity">Entity to insert (Id property must be setted)</param>
        void Delete(EntityType entity);
    }
}
